package com.itheima.HomeWork;

import java.util.Scanner;

public class HM09 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入身份证号：");
        String id = sc.nextLine();
        System.out.println(check(id));
    }
    public static boolean check(String id) {
        if (id == null) {
            return false;
        }
        if (id.startsWith("0")) {
            return false;
        }
        if (id.length() != 18) {
            return false;
        }
        for (int i = 0; i < id.length(); i++) {
            char ch = id.charAt(i);
            if (i == id.length() - 1) {
                if (ch < '0' || ch > '9' && ch != 'X') {
                    return false;
                }
            } else {
                if (ch < '0' || ch > '9') {
                    return false;
                }
            }
        }
        return true;
    }
}
